package com.ysxsoft.wdg.adapter.my;


import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.bean.response.ShouYiDetailResponse;
import com.ysxsoft.wdg.util.ViewUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SyAdapter extends BaseQuickAdapter<ShouYiDetailResponse.DataBean, BaseViewHolder> {


    private int type = 1;

    public SyAdapter(int layoutResId) {
        super(layoutResId);
    }

    public void clear() {
        getData().clear();
        notifyDataSetChanged();
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, ShouYiDetailResponse.DataBean item) {

       ViewUtils.loadCircleImage(mContext,item.getAvatar(),(ImageView) helper.getView(R.id.iv_tx));

        helper.setText(R.id.tv_nick,item.getName());//昵称
        helper.setText(R.id.tv_jb,item.getStyle()+"");
        if(item.getSta()==0){
            helper.setText(R.id.tv_money_name,"贡献佣金：");
        }else{
            helper.setText(R.id.tv_money_name,"返利：");
        }
        helper.setText(R.id.tv_money,item.getNum());
        helper.setText(R.id.tv_desc,item.getDesr());
        SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
        helper.setText(R.id.tv_time,dateFormat.format(new Date(item.getAddtime()*1000)));

        TextView tvTime = helper.getView(R.id.tv_time);
        TextView tvDesc = helper.getView(R.id.tv_desc);
        switch (type) {
            case 1:
                break;
            case 2:
                tvDesc.setVisibility(View.VISIBLE);
                tvTime.setVisibility(View.GONE);
                break;
            case 3:
            case 4:
            case 5:
                tvDesc.setVisibility(View.VISIBLE);
                tvTime.setVisibility(View.VISIBLE);
                break;
            case 6:
                tvDesc.setVisibility(View.GONE);
                tvTime.setVisibility(View.GONE);
                break;
        }
    }
}
